/**************************
 * \if English
 * @Date:2018.09.10
 * @Author:
 * @Brief:
 * @Detail:
 * @Editor:
 * @Brief:
 * \else
 *
 * @创建日期：2018年9月10日
 * @作者：hualei
 * @大概功能：TCP_START 指令
**************************/
#include "tcpstartinstruction.h"

TcpStartInstruction::TcpStartInstruction()
{
    tcpStartClientIPVec.resize(4);
    tcpStartServerIPVec.resize(4);
}

QDataStream& operator <<(QDataStream &out,TcpStartInstruction &myVector)
{
    out << (quint32)myVector.instructionType << (quint32)myVector.tcpStartBusType;

    if(myVector.tcpStartBusType == E_TCP_BUSTYPE_CLIENT)
    {
       out << myVector.tcpStartServerIPVec;
    }
    else if(myVector.tcpStartBusType == E_TCP_BUSTYPE_SERVER)
    {
       out << myVector.tcpStartClientIPVec;
    }
    out << myVector.tcpStartPort << myVector.jmpLabelValue << myVector.noteStr;

    return out;
}

QDataStream& operator >>(QDataStream &in,TcpStartInstruction &myVector)
{
    quint32 instructionType;
    quint32 busType;

    in >> instructionType >> busType;

    if(busType == E_TCP_BUSTYPE_CLIENT)
    {
       in >> myVector.tcpStartServerIPVec;

    }
    else if(busType == E_TCP_BUSTYPE_SERVER)
    {
       in >> myVector.tcpStartClientIPVec;
    }

    in >> myVector.tcpStartPort >> myVector.jmpLabelValue >> myVector.noteStr;

    myVector.instructionType = (INSTRUCTION_TYPE)instructionType;
    myVector.tcpStartBusType = (EM_TCP_BUSTYPE)busType;
    return in;

}
